﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SailHero.Soft.FrameWork.Models;
using UI.Web.SL.Demo.RIAServices.Web;

namespace UI.Web.Silverlight.Demo.Views
{
    public partial class LogListView : UserControl
    {
        private IEnumerable<LOG> _logList;
        private LogDContext _logDContext = new LogDContext();
        private LoadOperation<LOG> _loadLogListOperation;
        public LogListView()
        {
            InitializeComponent();
            LoadLog(null);
        }

        public void LoadLog(object o)
        {
            _loadLogListOperation = _logDContext.Load(_logDContext.GetLogsQuery());
            _loadLogListOperation.Completed += new EventHandler(_loadLogListOperation_Completed);
        }

        void _loadLogListOperation_Completed(object sender, EventArgs e)
        {
            this.LogList = _loadLogListOperation.Entities;
            this.dataGrid1.ItemsSource = LogList;
        }

        public IEnumerable<LOG> LogList
        {
            get { return _logList; }
            set
            {
                _logList = value;
            }
        }
    }
}
